<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>SysFindTran</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <link rel="stylesheet" href="../../layui-v2.6.8/layui/css/layui.css"  media="all">
    <script type="text/javascript" src="../../layui-v2.6.8/layui/layui.js"></script>
    <script type="text/javascript" src="../../js/jQuery%20v3.6.0.js"></script>

</head>
<body>

<fieldset class="layui-elem-field layui-field-title" style="margin-top: 20px;">
    <legend>管理员查询物流信息</legend>
</fieldset>

    <form class="layui-form" action="">
        <div class="layui-form-item">
            <div class="layui-inline">
                <div class="layui-inline">
                    <label class="layui-form-label" style="font-size: 16px">运输单号：</label>
                    <div class="layui-input-block">
                        <input type="text" id="tid" name="title" class="layui-input" style="width: 200px">
                    </div>
                </div>

                <div class="layui-inline">
                    <label class="layui-form-label">日期:</label>
                    <div class="layui-inline" id="range">
                        <div class="layui-input-inline">
                            <input type="text" lay-verify="date" autocomplete="off" name="startDate" id="startDate" class="layui-input" placeholder="开始日期">
                        </div>
                        <div class="layui-form-mid">-</div>
                        <div class="layui-input-inline">
                            <input type="text" lay-verify="date" autocomplete="off" name="endDate" id="endDate" class="layui-input" placeholder="结束日期">
                        </div>
                    </div>
                </div>

                <button type="button" id="find" class="layui-btn layui-btn-normal">查询</button>

            </div>

            <table class="layui-hide" id="systrans" lay-filter="operation"></table>

        </div>

    </form>

<script>

    var laydate = layui.laydate;
    var table = layui.table;

    layui.use(['table','laydate'], function(){

        table.render({
            elem: '#systrans'
            ,url:'http://localhost:8080/sys/findtrans'
            ,toolbar: '#toolbarDemo'
            ,defaultToolbar: ['filter', 'exports', 'print']
            ,page: true
            ,cols: [[
                {field:'tid',title: '运输单号', sort: true}
                ,{field:'oidt',title: '订单编号', sort: true}
                ,{field:'fidt',title: '中转地址'}
                ,{field:'tdate',title: '中转时间'}
                ,{field:'vidt',title: '车牌号'}
                ,{field:'eidt',title: '司机姓名'}
                ,{field:'sdate',title: '收货时间', sort: true}
            ]]
            ,page: true
        });
    });


    //查询
    $("#find").click(function () {
        var tid=$('#tid').val()
        var sdate=$('#startDate').val()
        var edate=$('#endDate').val()
        //日期
        laydate.render({
            elem: '#startDate'
        });
        laydate.render({
            elem: '#endDate'
        });
        laydate.render({
            elem: '#range' //开始时间和结束时间所在 input 框的父选择器
            //设置开始日期、日期日期的 input 选择器
            ,range: ['#startDate', '#endDate'] //数组格式为 layui 2.6.6 开始新增
        });
        //开始查询逻辑
        //id空
        if(tid==null||tid==undefined||tid==""){
            //时间空
            if( (sdate==null||sdate==undefined||sdate=="") || (edate==null||edate==undefined||edate=="") ){
                location.reload();
            //else_时间非空，按时间查
            }else {
                layer.open({
                    area: ['100%', '400px'], //宽高
                    title: ["查询结果", "align:center"],
                    maxmin: false,
                    content: '<div><table id="da"></table></div>',
                    success: function () {
                        table.render({
                            elem: '#da',
                            url: 'http://localhost:8080/sys/findtrans/ByDate?sdate=' + sdate + '&edate=' + edate,
                            page: true
                            , cols: [[
                                {field: 'tid', title: '运输单号', sort: true}
                                , {field: 'oidt', title: '订单编号', sort: true}
                                , {field: 'fidt', title: '中转地址'}
                                , {field: 'tdate', title: '中转时间'}
                                , {field: 'vidt', title: '车牌号'}
                                , {field: 'eidt', title: '司机姓名'}
                                , {field: 'sdate', title: '收货时间', sort: true}
                            ]]
                        });
                    }
                });
            }

        //else_id非空
        }else {
            //时间空，按id查
            if ( (sdate==null||sdate==undefined||sdate=="") || (edate==null||edate==undefined||edate=="") ){
                layer.open({
                    area: ['100%', '400px'], //宽高
                    title : ["查询结果","align:center"],
                    maxmin : false,
                    content : '<div><table id="t"></table></div>',
                    success: function () {
                        table.render({
                            elem: '#t',
                            url: 'http://localhost:8080/sys/findtrans/ById?tid='+ tid,
                            page: true
                            , cols: [[
                                {field:'tid',title: '运输单号', sort: true}
                                ,{field:'oidt',title: '订单编号', sort: true}
                                ,{field:'fidt',title: '中转地址'}
                                ,{field:'tdate',title: '中转时间'}
                                ,{field:'vidt',title: '车牌号'}
                                ,{field:'eidt',title: '司机姓名'}
                                ,{field:'sdate',title: '收货时间', sort: true}
                            ]]
                        });
                    }
                });
            //时间非空，id和时间多条件查询
            }else {
                layer.open({
                    area: ['100%', '400px'], //宽高
                    title: ["查询结果", "align:center"],
                    maxmin: false,
                    content: '<div><table id="by"></table></div>',
                    success: function () {
                        table.render({
                            elem: '#by',
                            url: 'http://localhost:8080/sys/findtrans/By?tid='+tid+'&sdate=' + sdate + '&edate=' + edate,
                            page: true
                            , cols: [[
                                {field: 'tid', title: '运输单号', sort: true}
                                , {field: 'oidt', title: '订单编号', sort: true}
                                , {field: 'fidt', title: '中转地址'}
                                , {field: 'tdate', title: '中转时间'}
                                , {field: 'vidt', title: '车牌号'}
                                , {field: 'eidt', title: '司机姓名'}
                                , {field: 'sdate', title: '收货时间', sort: true}
                            ]]
                        });
                    }
                });
            }
        }

    })



</script>

</body>
</html>